package com.chatsystem.util;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * 密码生成工具类
 * 用于生成BCrypt加密的密码，方便测试和数据库初始化
 * 
 * @author ChatSystem
 * @version 1.0.0
 */
public class PasswordGenerator {

    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        
        // 生成密码 "123456" 的BCrypt加密版本
        String password = "123456";
        String encodedPassword = encoder.encode(password);
        
        System.out.println("原始密码: " + password);
        System.out.println("BCrypt加密后: " + encodedPassword);
        
        // 验证密码
        boolean matches = encoder.matches(password, encodedPassword);
        System.out.println("密码验证: " + matches);
        
        // 生成SQL插入语句
        System.out.println("\nSQL插入语句:");
        System.out.println("INSERT INTO users (username, password, email, nickname) VALUES ");
        System.out.println("('admin', '" + encodedPassword + "', 'admin@example.com', '管理员'),");
        System.out.println("('user1', '" + encodedPassword + "', 'user1@example.com', '用户1'),");
        System.out.println("('user2', '" + encodedPassword + "', 'user2@example.com', '用户2');");
    }
} 